<?php

class pulseModel extends kseBasic{
    
    public function __construct() {
        $this->info("Core Model Initialized");
    }
    
    public function getResult($object){
        $this->info("Starting Modeling content of ". $object->getName());
        
        switch ($object->getName()) {
            case "root_categories":
                $this->makeMetaElement($object);
            break;
        }
        
        $this->info("Modeling - DONE");
        return Core::get()->nsControllers["pulseController"]->metaTemplate;
    }
    
    public function makeMetaElement($object) {
        ob_start();
        ob_implicit_flush(0);

        while ($row = mysql_fetch_array(Core::get()->nsControllers["pulseController"]->result, MYSQL_ASSOC)){
            $content = Core::get()->nsControllers["pulseController"]->metaTemplate;
            foreach($row as $key => $value){
                $content = str_replace("<%". $key ."%>", $value, $content);
            }
            echo $content;
        }
        
        $content = ob_get_contents();
        ob_end_clean();
        Core::get()->nsControllers["pulseController"]->metaTemplate = $content;
    }
    
}
?>